<!DOCTYPE html>
<html>
<head>
	<title>Group test page</title>
	<link rel="stylesheet" href="/css/test" type="text/css" />
</head>
<body>
<?php
require_once ('/f5/wsabey/protected/Group.php');
User::loadConfig ('/f5/wsabey/protected/test.cfg');
// Nuke test database; we want a clean slate
$dbPath = User::config ('db_path');
if (is_file ($dbPath))
	unlink ($dbPath);
User::setupDB ();
User::add ('Bob','bobspassword','bob@bob.com');
User::add ('Fred','fredspassword','fred@fred.com');
try
{
	print "<p>Testing invalid group name: 'A'</p>";
	Group::add ("A");
	print "<p class='fail'>Unexpected result; bad group name accepted.</p>";
}
catch (InvalidArgumentException $e)
{
	print "<p class='pass'>Expected result; InvalidArgumentException thrown.</p>";
}
catch (Exception $e)
{
	print "<p class='fail'>Unexpected result; Wrong exception thrown: ".get_class ($e)."</p>";
	print $e->getMessage ();
}
try
{
	print "<p>Testing valid group name: 'BobGroup'</p>";
	Group::add ("BobGroup");
	print "<p class='pass'>Expected result; valid group name accepted.</p>";
}
catch (Exception $e)
{
	print "<p class='fail'>Unexpected result; valid group name not accepted: ".get_class ($e)."</p>";
	print $e->getMessage ();
}
try
{
	print "<p>Testing duplicate group name: 'BobGroup'</p>";
	Group::add ("BobGroup");
	print "<p class='fail'>Unexpected result; duplicate group name accepted.</p>";
}
catch (InvalidArgumentException $e)
{
	print "<p class='pass'>Expected result; InvalidArgumentException thrown.</p>";
}
?>
</body>
</html>